 var App = {
     getToken: function () {
         return store.get('token');
     },
     getTokenHeader: function () {
         return {
             'Authorization': 'Bearer ' + App.getToken()
         };
     },
     handResponse: function (res) {
         if (res.success) {
             return res.result;
         } else {
             return res.error;
         }
     },
     ajaxJson: function (url, data, callback, headers = {}, method = 'get') {
         if (method.toLowerCase() == 'post') {
             headers = Object.assign(headers, {
                 'Content-Type': 'application/json-patch+json'
             })
         }
         $.ajax({
             type: method,
             dataType: 'json',
             url: store.get('remoteUrl') + url,
             data: method.toLowerCase() == 'post' ? JSON.stringify(data) : data,
             headers: Object.assign({}, headers, App.getTokenHeader()),
             success: function (res) {
                 let resData = App.handResponse(res);
                 callback(resData);
             },
             error: function (err) {
                 callback(resData);
             }
         });
     },
     formatDate: function (date, split = '-') {
         let d = new Date(date);
         let m = d.getMonth() + 1;
         let day = d.getDate();
         return d.getFullYear() + split + (m < 10 ? '0' + m : m) + split + (day < 10 ? '0' + day : day);
     }
 };

 var store = {
     _cache: {},
     getKey: function (k) {
         return 'store.eh5.' + k;
     },
     get: function (key) {
         return this._cache[this.getKey(key)];
     },
     set: function (key, value) {
         this._cache[this.getKey(key)] = value;
     }
 };